/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */
extern void mcu_disable_interrupt(void);
extern void mcu_enable_interrupt(void);
/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define TIM14_FREQ 84000000
#define TIM14_PWM_FREQ 1000
#define TIM14_INIT_PRELOAD 999
#define TIM14_PRESCALAR TIM14_FREQ/TIM14_PWM_FREQ/(TIM14_INIT_PRELOAD+1)
#define TIM7_FREQ 84000000
#define TIM7_PWM_FREQ 1000
#define TIM7_PRESCALAR 2
#define TIM7_PRELOAD (TIM7_FREQ/TIM7_PWM_FREQ/TIM7_PRESCALAR) - 1
#define ENC_INC_CPR 250
#define TIM8_INIT_PRELOAD (ENC_INC_CPR*4)-1
#define TIM_ENC_FILTER_VAL 6
#define GEAR_RATIO 109
#define ENC_INC_TOTAL_CNT ENC_INC_CPR*4*GEAR_RATIO
#define TIMF_FREQ 84000000
#define TIMF_PWM_FREQ 100
#define TIMF_INIT_PRELOAD 999
#define TIMF_PRESCALAR TIMF_FREQ/TIMF_PWM_FREQ/(TIMF_INIT_PRELOAD+1)
#define KEY2_Pin GPIO_PIN_2
#define KEY2_GPIO_Port GPIOE
#define KEY2_EXTI_IRQn EXTI2_IRQn
#define KEY1_Pin GPIO_PIN_3
#define KEY1_GPIO_Port GPIOE
#define KEY1_EXTI_IRQn EXTI3_IRQn
#define KEY0_Pin GPIO_PIN_4
#define KEY0_GPIO_Port GPIOE
#define KEY0_EXTI_IRQn EXTI4_IRQn
#define LED0_Pin GPIO_PIN_9
#define LED0_GPIO_Port GPIOF
#define LED1_Pin GPIO_PIN_10
#define LED1_GPIO_Port GPIOF
#define MOTOR_EN_Pin GPIO_PIN_6
#define MOTOR_EN_GPIO_Port GPIOA
#define MOTOR_PWM_Pin GPIO_PIN_7
#define MOTOR_PWM_GPIO_Port GPIOA
#define ENC_Z_EXIT_Pin GPIO_PIN_7
#define ENC_Z_EXIT_GPIO_Port GPIOG
#define RS485_RE_Pin GPIO_PIN_8
#define RS485_RE_GPIO_Port GPIOG
#define LIMIT_SWITCH_Pin GPIO_PIN_12
#define LIMIT_SWITCH_GPIO_Port GPIOC
#define LIMIT_SWITCH_EXTI_IRQn EXTI15_10_IRQn
/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
